<?php 
include('./fun.php');
$conn=my_sql($cfg);
$re=adm_login();
if($re['err']=='no_login'){no_login();}
$adm=$re['adm'];

$sql='select * from '.$cfg['e'].'emoji order by o desc,id asc ';
$l=db($sql);



?>
<style>
emoji_item{float:left;width:80px;height:80px;margin:5px;background:#fff;line-height:60px;font-size:30px;text-align:center;}
emoji_item view{float:left;width:100%;font-size:12px;text-align:center;height:20px;line-height:20px;}
emoji_item text{float:left;width:40px;}
</style>
<hh><b>Emoji图标管理</b></hh>
<mm>
<index>
<a class="m b" onclick="emoji_edit($(this))">添加emoji</a>
</index>
<?php 
if($l){
foreach($l as $v){
echo '<emoji_item><a>'.$v['emoji'].'</a><view><text onclick="em_up($(this))" i="'.$v['id'].'">置顶</text><text onclick="em_del($(this))" i="'.$v['id'].'">删除</text></view></emoji_item>';
}

}else{no_data();}


?>

</mm>
<script>
function emoji_edit(){
var h='<input id="val" placeholder="请输入emoji图标内容" style="float:left;width:100%;height:50px;line-height:50px;font-size:20px;">';
h+='<index><a class="m b" onclick="emoji_submit($(this))">添加图标</a></index>';
win({title:'emoji图标',html:h,width:600})

}

function emoji_submit(){
    var val=$('#val').val();
    if(!val){msg('请输入图标');return;}
    var data={emoji:val}

post('emoji_add',data,'',function(res){
    $('#val').val('');
    main_load();
    win_close();
    
});
}

function em_up(o){
var id=o.attr('i');
post('emoji_up','',id,function(res){
    main_load();
});

}

function em_del(o){
var id=o.attr('i');
if(!confirm("是否删除?")){return;}
post('emoji_del','',id,function(res){
    main_load();
});

}

</script>